import React, { useEffect, useRef } from 'react';

function VideoComponent({index}:{index: number}) {
  const videoRef = useRef<HTMLVideoElement>(null);

  useEffect(() => {
    navigator.mediaDevices.getUserMedia({ video: true })
      .then(stream => {
        if (videoRef.current) {
          videoRef.current.srcObject = stream;
        }
      })
      .catch(err => console.error(err));
  }, []);

  return (
    <video key={ index} ref={videoRef} autoPlay muted controls={false}>
                {/* <source src={"/video.mp4"} type="video/mp4" /> */}
              </video>
  );
}

export default VideoComponent;